<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<meta http-equiv="pragma" content="no-cach" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />

<title>无标题文档</title>
<style>
body{margin:0px;  }
li{list-style-type:hiragana;}
@font-face {
				font-family: 'inconsolata';
				src: url('../inc/inconsolata.woff') format('woff');
				font-weight: normal;
				font-style: normal;
			}

</style>
<script src="../inc/tools.build.js" type="text/javascript"></script>
<script src="../o/jquery-2.1.1.js"></script>
<script src="../AppVideo/TOOLS.Status.js"></script>
<script src="../AppVideo/mouse.js"></script>
<script src="../AppVideo/Video.lib.js"></script>
<script src="../AppVideo/initPage.js"></script>
<script src="../AppVideo/plug_volume.js"></script>
<script src="../AppVideo/_subtitle_H_.js"></script>
<script src="../AppVideo/plug_subtitle3.js"></script>
 

<?php
/*fileName: 
 *internal version: 0001
 *version : 1.0.0 [programming] [official version]
 *author : HeShengyu
 *Date : 2014.07.21 
 *email: koolfer@163.com
 *end date:2014.08.23
 *http://www.cnblogs.com/ssnowy/
*/
?>

</head>
<body>
<?php
  //php代码放到script标签就不会不空白现象出现
require_once 'appInc.php';
$filename =preg_replace(  array("/\\\\+/","/\/+/"),array("/","/") ,$_REQUEST['filename']);
$filename = preg_replace('/\.\.\//','',$filename);
if($filename==''){
$filename ='resoure2.txt' ;	
}
class Clrc{
    public static function file($filename){
	    $aContent=file($filename);	
		return $aContent ;
	}
	public static function fileShuffle($filename){
	    $aContent=file($filename);
		shuffle($aContent);	
		return $aContent ;
	}
	public static function arrayConvert($aContent='',$numberOfColumns = 4){
		if(!is_array($aContent)){
		    return array();	
		}
		$length = count($aContent);
        $retarr=array();
		 $st=0;
		for ($x=0; $x< $length; $x+=$numberOfColumns) {
			 $str='';
			 for($j=0;$j<$numberOfColumns;$j++){
				 if($x+$j<$length){
			 	 //$str .=preg_replace(array('/[0-9]{1,}[\.]?/','/\r*\n*/')
				 //,array(' ',''),$aContent[$x+$j]).'';
				 //$str .=$aContent[$x+$j];
				  $str  =$str.preg_replace( '/(\r\n)+/','<br>',$aContent[$x+$j]  );
				 }
			 }
			    
				 $s=$st=$st+6000;
				  
				 if($x<$length-$numberOfColumns){
				     $str= '{"s":'.$st.',"e": '.($st+5800).',"lyric":"'._escapeChars_2($str).'"},' ."\r\n";
				 }else{
				     $str= '{"s":'.$st.',"e": '.($st+5800).',"lyric":"'._escapeChars_2($str).'"}' ."\r\n";	 
				 }
             $retarr[]=$str;
        } 
		 
	    return $retarr;	
	}	
	public static function arr2str($aContent,$numberOfColumns = 4){
		$arr=self::arrayConvert($aContent,$numberOfColumns);
	    return "[".implode("",$arr)."]";	
	}	
	
}
function _pathtosimpleName($s){
    return preg_replace('/(.{0,}?)([0-9a-zA-Z\-_\.\$]{0,})(html|php|htm|txt)$/','\\2\\3',$s);	
	
}
//把自己生成一个html文件
// generation_selfhtml();
$aContent=(Clrc::file($filename));
$table = new Cltable;
//$arr=Clrc::arrayConvert($aContent);
// $table->export($arr,20);
 
$str=Clrc::arr2str($aContent,2);
 //echo $str;
$outcom=Cmkdirs::advancedFwf( '/a/root/'._pathtosimpleName($filename).'-res.lrc.txt',$str ,__FILE__  );
//$outcom=Cmkdirs::advancedFwf( '/a/root/res.lrc.txt',$str ,__FILE__,"D:/" );
echo pre_print_r(_pathtosimpleName($filename).'-res.lrc.txt');
echo $outcom?'ok':'failed';
//print_r($aContent);
?> 
</body>
</html>